package com.neuedu.api.collection;

import java.util.Arrays;

/**
 * @author 金山
 * 项目：javase
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2024/10/2414:33
 */
public class Runner {

    static Student stus[] = new Student[3];
    static int size = 0;

    public static void main(String[] args) {


        addStu( new Student("刘备"));
        System.out.println("getSize() = " + getSize());
        addStu( new Student("关于"));
        System.out.println("getSize() = " + getSize());
        addStu( new Student("张飞"));
        System.out.println("getSize() = " + getSize());


        list();

        addStu( new Student("诸葛亮"));
        System.out.println("getSize() = " + getSize());

    }


    public static  void addStu(Student student){

        if(size == stus.length){
            Student[] old = stus; //3
            // stus = new Student[size + 10];
            stus = Arrays.copyOf(old,size + 10);
        }
        stus[size++] = student;
    }

    public static int getSize(){
        return  size;
    }

    public static Object get(int index){
        return  stus[index];
    }

    // public static int remove(int i ){
    //     // stus[i]   //
    //     return  size;
    // }


    public static void list(){
        for (int i = 0; i < stus.length; i++) {
            System.out.println("stus[i] = " + stus[i]);
        }
    }


}
